using System.ServiceProcess;

namespace TripleA.Core.Extensions.WindowsService
{
    public enum WindowsServiceActionTypes
    {
        Start,
        Stop
    }

    /// <summary>
    /// This step can control a windows service
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class WindowsServiceControlStep<T> : WindowsServiceInstalledStep<T>
    {
        public WindowsServiceActionTypes Action { get; set; }

        protected override void Inspect(ServiceController serviceController)
        {
            switch (Action)
            {
                case WindowsServiceActionTypes.Start:
                    serviceController.Start();
                    break;

                case WindowsServiceActionTypes.Stop:
                    serviceController.Stop();
                    break;
            }            
        }
    }
}